package com.huawei.cartservice.controller;


import com.huawei.cartservice.pojo.dto.cartDTO;
import com.huawei.cartservice.service.CartService;
import com.huawei.common.pojo.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "购物车模块")
@RestController
@RequestMapping("/carts")
public class CartController {

    @Autowired
    private CartService cartService;
    






    @Operation(summary = "添加购物车")
    @PostMapping("/add")
    public Result addCart(@RequestHeader("Authorization") String token, @RequestBody List<cartDTO> cartDTO){
        return cartService.addCart(cartDTO);
    }

    @Operation(summary = "删除购物车")
    @DeleteMapping("/delete/{id}")
    public Result deleteCart(@RequestHeader("Authorization") String token,@PathVariable Long id){
        return cartService.deleteCart(id);
    }


    @Operation(summary = "查询购物车")
    @GetMapping("/{id}")
    public Result getCart(@RequestHeader("Authorization") String token,@PathVariable Long id){
        return cartService.getCart(token,id);
    }

































}
